board = []
used = set()
for _ in range(3):
    nums = list(map(int, input().split()))
    for num in nums:
        used.add(num)
    board.append(nums)


def check():
    for i in range(3):
        if sum(board[i]) != 15: return False
        if board[0][i] + board[1][i] + board[2][i] != 15: return False
    if board[0][0] + board[1][1] + board[2][2] != 15: return False
    if board[2][0] + board[1][1] + board[0][2] != 15: return False
    return True


def backtravel(i):
    if i == 9:
        if check():
            return True
        return False
    x, y = i // 3, i % 3
    if board[x][y] > 0:
        return backtravel(i + 1)
    for j in range(1, 10):
        if j in used: continue
        used.add(j)
        board[x][y] = j
        if backtravel(i + 1):
            return True
        board[x][y] = 0
        used.remove(j)
    return False


backtravel(0)
print(board)
